package com.sharding.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sharding.dao.TestUserDao;
import com.sharding.entity.UserDTO;
import com.sharding.utils.RandomAddressUtils;
import com.sharding.utils.RandomNameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Random;

/**
 * @author: LCG
 * @date: 2022-11-09 16:14:11
 * @description:
 **/
@Service
public class TestShardingService extends ServiceImpl<TestUserDao,UserDTO> implements TestService {

    @Autowired
    private TestUserDao testUserDao;

    /**
     * @author: LCG
     * @date: 2022-11-09 16:17:22
     * @description:  将数据导入到分库分表的表中
     */
    public Object insertToShardingDataBase(){

        return null;
    }


    @Override
    public void insertUserDto(){
        for (int i=0;i<100;i++){
            UserDTO userDTO=new UserDTO();
            String randomName = RandomNameUtils.getRandomName();
            userDTO.setUserName(randomName);
            userDTO.setPath(RandomAddressUtils.getRandomAddress());
            int nextInt = new Random().nextInt(3);
            userDTO.setBuMen("部门-"+nextInt);
            userDTO.setCreateTime(new Date());
            userDTO.setLoginName(randomName);
            userDTO.setSex(RandomNameUtils.getSex());
            userDTO.setSalt("12355");
            save(userDTO);
        }
    }

    @Override
    public void selectByName(String userName){

    }

}
